<?php

require_once(sfConfig::get('sf_lib_dir').'/filter/doctrine/BaseFormFilterDoctrine.class.php');

/**
 * Rendicion filter form base class.
 *
 * @package    filters
 * @subpackage Rendicion *
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 11675 2008-09-19 15:21:38Z fabien $
 */
class BaseRendicionFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'año'           => new sfWidgetFormFilterInput(),
      'lugar'          => new sfWidgetFormFilterInput(),
      'fecha'          => new sfWidgetFormFilterInput(),
      'motivo'         => new sfWidgetFormFilterInput(),
      'fecha_inicio'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'fecha_fin'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'id_solicitud'   => new sfWidgetFormDoctrineChoice(array('model' => 'Solicitud', 'add_empty' => true)),
      'id_dependencia' => new sfWidgetFormDoctrineChoice(array('model' => 'Dependencia', 'add_empty' => true)),
      'id_transporte'  => new sfWidgetFormDoctrineChoice(array('model' => 'Transporte', 'add_empty' => true)),
    ));

    $this->setValidators(array(
      'año'           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'lugar'          => new sfValidatorPass(array('required' => false)),
      'fecha'          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'motivo'         => new sfValidatorPass(array('required' => false)),
      'fecha_inicio'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'fecha_fin'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'id_solicitud'   => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Solicitud', 'column' => 'id')),
      'id_dependencia' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Dependencia', 'column' => 'id')),
      'id_transporte'  => new sfValidatorDoctrineChoice(array('required' => false, 'model' => 'Transporte', 'column' => 'id')),
    ));

    $this->widgetSchema->setNameFormat('rendicion_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Rendicion';
  }

  public function getFields()
  {
    return array(
      'id'             => 'Number',
      'año'           => 'Number',
      'lugar'          => 'Text',
      'fecha'          => 'Number',
      'motivo'         => 'Text',
      'fecha_inicio'   => 'Date',
      'fecha_fin'      => 'Date',
      'id_solicitud'   => 'ForeignKey',
      'id_dependencia' => 'ForeignKey',
      'id_transporte'  => 'ForeignKey',
    );
  }
}